package com.xhh.nphm.web.controller.system;

import com.xhh.nphm.common.core.controller.BaseController;
import com.xhh.nphm.common.core.domain.AjaxResult;
import com.xhh.nphm.common.core.domain.entity.SysUser;
import com.xhh.nphm.system.domain.SmsNote;
import com.xhh.nphm.system.service.ISmsNoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/smsNote")
public class SmsNoteController extends BaseController {

    @Autowired
    ISmsNoteService smsNoteService;

    /**
     * 是否发送短信
     * @return
     */
    @PostMapping("/isNote")
    public AjaxResult updateSmsInform(SmsNote smsNote){
        SysUser sysUser = getSysUser();
        smsNote.setDeptNo(sysUser.getDeptId());
        smsNote.setDeptName(sysUser.getDeptName());
        smsNote.setOptUserId(sysUser.getUserId());
        smsNote.setOptUser(sysUser.getUserName());
        smsNote.setOptTime(new Date());
        if (!smsNoteService.updateState(smsNote)) {
            return AjaxResult.error("修改失败");
        }
        return AjaxResult.success("修改成功");
    }
}
